package com.charm.xft.bill.controller;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.charm.xft.bill.entity.XftConfig;
import com.charm.xft.bill.service.IXftConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author baomidou
 * @since 2023-03-27
 */
@Controller
@RequestMapping("/bill")
public class XftBillController {

    @Autowired
    IXftConfigService xftConfigService;

    @GetMapping("sync")
    @ResponseBody
    public Object syncByTime(@RequestParam("time") String date) {
        DateTime parse = DateUtil.parse(date);
        XftConfig xftConfig = new XftConfig();
        xftConfig.setLastTime(parse.toLocalDateTime());
        xftConfig.setId(1L);
        xftConfigService.updateById(xftConfig);
        return "同步命令下发成功";
    }

}
